package com.wiz.web.controllor;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wiz.common.ResponseCode;
import com.wiz.service.StationMonitorService;
import com.wiz.to.OilTankMonitorHistoryTO;
import com.wiz.to.fpMonitorHistoryTO;
import com.wiz.vo.CollectionVO;
import com.wiz.vo.criteria.MonitorSearchCriteriaTO;
/**
 * 油站监控
 * @author xxy
 *
 */
@Controller
@RequestMapping("/stationMonitor")
public class StationMonitorControllor implements ResponseCode{
	private transient final Logger log=LoggerFactory.getLogger(getClass());
	@Resource
	private StationMonitorService stationMonitorService;
	
	/**状态*/
	@RequestMapping(value="/listStatus")
	@ResponseBody
	public String listStatus(HttpServletRequest request,HttpServletResponse response,
			@RequestParam(value = "numPerPage", required = false,defaultValue="10") int pageSize,
			@RequestParam(value = "pageNum", required = false,defaultValue="1") int pageNo,
//			@RequestParam(value = "pageNum", required = false,defaultValue="1") int pageNo,
//			@RequestParam(value = "pageNum", required = false,defaultValue="1") int pageNo,
			HttpSession session, Model model){
		
		
		
		return null;
		
	}
	/**油罐状态*/
	@RequestMapping(value="/listOilTankStatus")
	public String listOilTankStatus(HttpServletRequest request,HttpServletResponse response,
			@RequestParam(value = "numPerPage", required = false,defaultValue="10") int pageSize,
			@RequestParam(value = "pageNum", required = false,defaultValue="1") int pageNo,
			@RequestParam(value = "hqId", required = false) String hqId,
			@RequestParam(value = "hqName", required = false) String hqName,
			@RequestParam(value = "stationId", required = false) String stationId,
			@RequestParam(value = "stationName", required = false) String stationName,
			HttpSession session, Model model){
		MonitorSearchCriteriaTO monitorSearchCriteriaTO = new MonitorSearchCriteriaTO(hqId, hqName,
				stationId, stationName, pageSize, pageNo, (pageNo > 0 && pageSize > 0));
				
		
		List<OilTankMonitorHistoryTO> agentTOs=stationMonitorService.getOilTankListByCriteriaTO(monitorSearchCriteriaTO);
		int totalCount=stationMonitorService.getOilTankCntByCriteriaTO(monitorSearchCriteriaTO);
		CollectionVO collectionTO=new CollectionVO(agentTOs, totalCount, pageSize, pageNo);
		model.addAttribute("collectionTO", collectionTO);
		model.addAttribute("totalCount", totalCount);
		model.addAttribute("pageNumShow", totalCount/pageSize+((totalCount%pageSize>0)?1:0));
		model.addAttribute("searchCriteria", monitorSearchCriteriaTO);
		
		return "station/monitor/oilTanklist";
		
	}
	/**油枪监控记录*/
	@RequestMapping(value="/listFPhistory")
	public String listFPhistory(HttpServletRequest request,HttpServletResponse response,
			@RequestParam(value = "numPerPage", required = false,defaultValue="10") int pageSize,
			@RequestParam(value = "pageNum", required = false,defaultValue="1") int pageNo,
			@RequestParam(value = "hqId", required = false) String hqId,
			@RequestParam(value = "hqName", required = false) String hqName,
			@RequestParam(value = "stationId", required = false) String stationId,
			@RequestParam(value = "stationName", required = false) String stationName,
			HttpSession session, Model model){
			
		MonitorSearchCriteriaTO monitorSearchCriteriaTO = new com.wiz.vo.criteria.MonitorSearchCriteriaTO(hqId, hqName,
				stationId, stationName, pageSize, pageNo, (pageNo > 0 && pageSize > 0));
				
		
		List<fpMonitorHistoryTO> agentTOs=stationMonitorService.getFPhistoryListByCriteriaTO(monitorSearchCriteriaTO);
		int totalCount=stationMonitorService.getFPhistoryCntByCriteriaTO(monitorSearchCriteriaTO);
		CollectionVO collectionTO=new CollectionVO(agentTOs, totalCount, pageSize, pageNo);
		model.addAttribute("collectionTO", collectionTO);
		model.addAttribute("totalCount", totalCount);
		model.addAttribute("pageNumShow", totalCount/pageSize+((totalCount%pageSize>0)?1:0));
		model.addAttribute("searchCriteria", monitorSearchCriteriaTO);
		return "station/monitor/FPlist";
		
				
		
	}
	

}
